import { pageHandler } from '@/mixins/pageHandler'
import MonitorHeader from '@/components/MonitorHeader/MonitorHeader.vue'
import ScaleBox from '@/components/ScaleBox/ScaleBox.vue'
import YingYaBan from '@/components/controls/YingYaBan.vue'
import NetState from '@/components/controls/netState.vue'
import RuanYaBan from '@/components/controls/RuanYaBan.vue'
import GuangZiPai from '@/components/controls/GuangZiPai.vue'
import BiLeiQi from '@/components/controls/biLeiQi.vue'
import XianQuan from '@/components/controls/xianquan.vue'
import TerminalSvg from '@/components/controls/terminal-svg.vue'
import ConnectLine from '@/components/controls/connect-line.vue'
import RectSvg from '@/components/controls/rect-svg.vue'
import KongZhiBaShou from '@/components/controls/KongZhiBaShou.vue'
import RightClickmenuList from '@/components/rightClickmenuList/rightClickMenuList.vue'
import GuapaiDialog from '@/components/rightClickmenuList/guapaiDialog.vue'
import YaokongDialog from '@/components/rightClickmenuList/yaokongDialog.vue'

export default {
	name: 'Guiping220kV253',
	components: {
		YaokongDialog,
		GuapaiDialog,
		RightClickmenuList,
		KongZhiBaShou,
		RectSvg,
		ConnectLine,
		TerminalSvg,
		XianQuan,
		BiLeiQi,
		GuangZiPai,
		RuanYaBan,
		NetState,
		YingYaBan,
		ScaleBox,
		MonitorHeader
	},
	mixins: [pageHandler],
	data() {
		return {
			netStateList: [],
			flexiblePlatenDataList: []
		}
	},
	created() {

	},
	methods: {
		getColor(name) {
			const lowerName = name.toLowerCase();
			if (lowerName === 'ia' || lowerName === 'ua') {
				return 'yellow'
			} else if (lowerName === 'ib' || lowerName === 'ub') {
				return 'rgb(0,210,0)'
			} else if (lowerName === 'ic' || lowerName === 'uc') {
				return 'rgb(210,0,0)'
			} else {
				return 'rgb(128,0,128)'
			}
		},
		initData(e) {
			this.filterData(e)
		},
		filterData(data) {
			const typeMap = {
				"压板": 'hardPlatenDataList',
				"软压板": 'flexiblePlatenDataList',
				"光字牌": 'GZPDataList',
				"网络状态": 'netStateList'
			}

			for (const listName of Object.values(typeMap)) {
				this[listName] = []
			}
			for (const [key, value] of Object.entries(data)) {
				for (const [type, listName] of Object.entries(typeMap)) {
					const filtered = value.filter((item) => item.type === type)
					if (filtered.length > 0) {
						this[listName].push({
							name: key,
							list: filtered
						})
					}
				}
			}
		}
	},
	mounted() {},
	destroyed() {

	},
	watch: {

	}
}